using System;
using JNPF.Basics.Models;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using JNPF.Utils;
using System.Transactions;

namespace JNPF.Basics.Logic
{
    public class CustomeractualcontrollerBll
    {
        private CustomeractualcontrollerIService service = new CustomeractualcontrollerService();


		/// <summary>
		/// 获取信息
		/// </summary>
		/// <param name="id">主键值</param>
		/// <returns></returns>
		public async Task<CustomeractualcontrollerEntity> GetInfo(int id)
		{
			try
			{
				return await service.GetInfo(id);
			}
			catch (Exception ex)
			{
				throw ExceptionEx.Throw(ex);
			}
		}

		/// <summary>
		/// 获取列表
		/// </summary>
		/// <param name="input">请求参数</param>
		/// <returns></returns>
		public async Task<PageResult<CustomeractualcontrollerEntity>> GetPageList(CustomeractualcontrollerListQueryInput input)
		{
			try
			{
				return await service.GetPageList(input);
			}
			catch (Exception ex)
			{
				throw ExceptionEx.Throw(ex);
			}
		}

		/// <summary>
		/// 创建信息
		/// </summary>
		/// <param name="entity">实体对象</param>
		/// <returns></returns>
		public async Task<int> Create(CustomeractualcontrollerEntity entity)
		{
			try
			{
                entity.CreatorTime = DateTime.Now;
                entity.CreatorUserId = UserProvider.Instance.Get().UserId;
                entity.CreatorUser = UserProvider.Instance.Get().UserName;
                entity.DeleteMark = 0;
                entity.EnabledMark = 1;
                return await service.Create(entity);
			}
			catch (Exception ex)
			{
				throw ExceptionEx.Throw(ex);
			}
		}

		/// <summary>
		/// 更新信息
		/// </summary>
		/// <param name="id">主键值</param>
		/// <param name="entity">实体对象</param>
		/// <returns></returns>
		public async Task<int> Update(int id, CustomeractualcontrollerEntity entity)
		{
			try
			{
                entity.Id = id;
                entity.LastModifyTime = DateTime.Now;
                entity.LastModifyUserId = UserProvider.Instance.Get().UserId;
                return await service.Update(entity);
			}
			catch (Exception ex)
			{
				throw ExceptionEx.Throw(ex);
			}
		}

		/// <summary>
		/// 删除信息
		/// </summary>
		/// <param name="entity">实体对象</param>
		/// <returns></returns>
		public async Task<int> Delete(CustomeractualcontrollerEntity entity)
		{
			try
			{
                entity.DeleteMark = 1;
                entity.DeleteTime = DateTime.Now; ;
                entity.DeleteUserId = UserProvider.Instance.Get().UserId;

                return await service.Update(entity);
            }
			catch (Exception ex)
			{
				throw ExceptionEx.Throw(ex);
			}
		}

		/// <summary>
		/// 获取列表
		/// </summary>
		/// <param name="input">过滤条件</param>
		/// <returns></returns>
		public async Task<List<CustomeractualcontrollerEntity>> GetList(CustomeractualcontrollerListQueryInput input)
		{
			try
			{
				return await service.GetList(input);
			}
			catch (Exception ex)
			{
				throw ExceptionEx.Throw(ex);
			}
		}


    }
}